package com.smartscreen.lifeserviceinfomanage.service.impl;

import com.smartscreen.lifeserviceinfomanage.dto.WeatherForecastDTO;
import com.smartscreen.lifeserviceinfomanage.dto.WeatherNowDTO;
import com.smartscreen.lifeserviceinfomanage.service.WeatherService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class WeatherServiceImpl implements WeatherService {
    
    @Override
    public WeatherNowDTO getCurrentWeather() {
        // 这里应该调用第三方天气API，此处返回模拟数据
        WeatherNowDTO weather = new WeatherNowDTO();
        weather.setLocation("上海");
        weather.setTemperature("28");
        weather.setWeatherText("多云");
        weather.setWeatherCode("4");
        weather.setHumidity("75%");
        weather.setWindDirection("东南风");
        weather.setWindScale("3级");
        return weather;
    }
    
    @Override
    public List<WeatherForecastDTO> getWeatherForecast(Integer days) {
        // 这里应该调用第三方天气API，此处返回模拟数据
        List<WeatherForecastDTO> forecasts = new ArrayList<>();
        
        WeatherForecastDTO forecast1 = new WeatherForecastDTO();
        forecast1.setDate("2025-07-15");
        forecast1.setDayWeather("雷阵雨");
        forecast1.setNightWeather("多云");
        forecast1.setHighTemp("32");
        forecast1.setLowTemp("26");
        forecasts.add(forecast1);
        
        WeatherForecastDTO forecast2 = new WeatherForecastDTO();
        forecast2.setDate("2025-07-16");
        forecast2.setDayWeather("多云");
        forecast2.setNightWeather("晴");
        forecast2.setHighTemp("33");
        forecast2.setLowTemp("27");
        forecasts.add(forecast2);
        
        return forecasts.subList(0, Math.min(days != null ? days : 3, forecasts.size()));
    }
}